1 00:00:00,290 --> 00:00:01,190 Welcome back. 2 00:00:01,190 --> 00:00:05,960 In this lecture we're going to finish up our admin system by creating some common commands that many 3 00:00:05,960 --> 00:00:07,370 admin systems have. 4 00:00:07,370 --> 00:00:09,050 So let's just go ahead and get started. 5 00:00:09,050 --> 00:00:14,210 One common command that a lot of admin systems have is setting the speed of a player. 6 00:00:14,210 --> 00:00:19,640 So here let's go ahead and override this example command to be a speed command. 7 00:00:19,640 --> 00:00:22,280 So the key for this command I'm going to set to speed. 8 00:00:22,580 --> 00:00:26,660 And I'll just set the name of this command uh set speed. 9 00:00:27,240 --> 00:00:32,790 The minimum rank we could keep at moderator, and the usage we can keep at set speed speed, and we 10 00:00:32,790 --> 00:00:35,430 can add even another usage like walk speed. 11 00:00:36,400 --> 00:00:40,150 And then for the parameters, we don't need to change anything because we're going to take a player 12 00:00:40,150 --> 00:00:41,170 and then a number. 13 00:00:41,170 --> 00:00:45,940 And then here for the parameters, we're going to have to change this, because the first parameter 14 00:00:45,940 --> 00:00:50,740 that gets passed to our lambda function is going to be the caller, or aka the person executing the 15 00:00:50,740 --> 00:00:51,430 command. 16 00:00:51,430 --> 00:00:56,860 The next parameter should be our player or that table containing all the players. 17 00:00:56,860 --> 00:00:58,840 So we're going to call it players. 18 00:00:58,840 --> 00:01:02,500 And it's going to be a table containing uh players. 19 00:01:02,500 --> 00:01:05,260 So if it's just one player it'll contain one player. 20 00:01:05,260 --> 00:01:08,140 But if it's multiple it contain multiple and so on. 21 00:01:08,530 --> 00:01:13,870 And then the last parameter we have passed is a number to represent the new speed we want to set for 22 00:01:13,870 --> 00:01:14,890 all the players. 23 00:01:15,430 --> 00:01:21,250 So then what we could do here is we could loop through every single player that is inside of our players 24 00:01:21,250 --> 00:01:22,030 table. 25 00:01:22,300 --> 00:01:28,660 And what we could check here is, first of all, we need to verify if this player actually has a character. 26 00:01:28,660 --> 00:01:33,160 If they don't have a character, then we're just going to continue looping because we cannot set the 27 00:01:33,160 --> 00:01:35,620 walk speed of a player that doesn't have a character. 28 00:01:35,620 --> 00:01:44,530 Otherwise we could do player character dot humanoid, dot walk speed is equal to the new speed, and 29 00:01:44,530 --> 00:01:48,940 then once we're done looping, we can return true and say that we've successfully executed the command 30 00:01:49,150 --> 00:01:50,080 and that's it. 31 00:01:50,080 --> 00:01:54,040 So if we go ahead and test out our game, our command should work just fine. 32 00:01:54,900 --> 00:01:57,630 So let's go ahead and hit a semicolon here. 33 00:01:58,340 --> 00:02:02,930 Type in our colon, and we could do set speed and we could do me, and then we could set our speed to 34 00:02:02,930 --> 00:02:04,160 something like 120. 35 00:02:04,190 --> 00:02:05,090 We hit enter. 36 00:02:05,270 --> 00:02:06,740 Executed successfully. 37 00:02:06,740 --> 00:02:09,020 And now if we walk around, boom! 38 00:02:09,020 --> 00:02:16,970 We are super fast now and then again we can do set speed me and then do a number like 16. 39 00:02:16,970 --> 00:02:18,920 And now our walk speed is back to normal. 40 00:02:19,100 --> 00:02:21,470 Now let's go ahead and test out our message label. 41 00:02:21,470 --> 00:02:26,480 So let's say we do set speed and we try to pass the name of a player that doesn't exist. 42 00:02:26,480 --> 00:02:30,800 Like what if we do um others 100. 43 00:02:30,800 --> 00:02:33,110 There's going to be no others in the game. 44 00:02:33,110 --> 00:02:35,300 So it should tell us that no players exist. 45 00:02:35,960 --> 00:02:38,180 And unfortunately it looks like we got an error. 46 00:02:38,180 --> 00:02:40,310 So let's go ahead and see what our error is. 47 00:02:41,720 --> 00:02:44,870 Attempt to call a table value. 48 00:02:45,990 --> 00:02:54,840 Oh, I see, um, we couldn't display the message because we forgot to call our new function. 49 00:02:55,020 --> 00:02:55,380 Oops. 50 00:02:55,380 --> 00:02:57,870 We forgot to call the constructor, but that's fine. 51 00:02:57,870 --> 00:02:58,830 We just fixed that. 52 00:02:58,830 --> 00:03:04,110 So let's go ahead and apply those script changes and let's try that out again. 53 00:03:04,110 --> 00:03:10,680 So if we do set speed others and do something like 100 there we go. 54 00:03:10,680 --> 00:03:11,520 We get a notice. 55 00:03:11,520 --> 00:03:12,990 No players exist. 56 00:03:12,990 --> 00:03:17,490 So if we try to do set speed and then we pass a name like Jeff 100. 57 00:03:17,490 --> 00:03:19,500 Again no players exist. 58 00:03:19,650 --> 00:03:24,120 If we try to use the command and we don't pass the correct number of parameters. 59 00:03:24,120 --> 00:03:28,800 So what if we just do me and then we don't supply a number, then we're going to get missing arguments 60 00:03:28,800 --> 00:03:29,640 to command. 61 00:03:29,640 --> 00:03:30,360 Oh no. 62 00:03:30,540 --> 00:03:35,820 If we do set speed me and then we don't pass a number but instead we pass something like that, then 63 00:03:35,820 --> 00:03:40,350 we're going to get an error command set speed expected number for argument number two. 64 00:03:40,350 --> 00:03:42,600 But we got nil instead. 65 00:03:42,990 --> 00:03:46,950 Anyways, another cool command we could do is killing other players. 66 00:03:46,950 --> 00:03:49,440 So we can call this command kill. 67 00:03:49,440 --> 00:03:52,710 And we can just basically copy all of this here. 68 00:03:52,950 --> 00:03:54,720 And then just kind of override all of this. 69 00:03:54,720 --> 00:03:56,850 So we can call this command kill. 70 00:03:56,850 --> 00:03:59,190 We can keep it at moderator. 71 00:03:59,400 --> 00:04:02,730 The usage for this would be like kill. 72 00:04:03,210 --> 00:04:05,550 I think that's the only usage you'd want for this command. 73 00:04:05,550 --> 00:04:11,100 And then of course, we only need a player for this command so we can get rid of our new speed parameter. 74 00:04:11,100 --> 00:04:13,980 And when we want to do is we want to loop through every single player. 75 00:04:13,980 --> 00:04:20,610 And if they have a character, we can do player dot, character humanoid and set the health of the humanoid 76 00:04:20,610 --> 00:04:21,240 to zero. 77 00:04:21,240 --> 00:04:24,600 So it should be able to kill all the players passed to our callback function. 78 00:04:24,600 --> 00:04:29,790 Let's go ahead and do some other popular commands like kicking players so we can call this command kick, 79 00:04:29,790 --> 00:04:32,010 where again, we're going to copy all this. 80 00:04:33,280 --> 00:04:37,600 And for this one we can keep it at moderator as well. 81 00:04:37,600 --> 00:04:39,880 We're going to call this command kick. 82 00:04:39,880 --> 00:04:44,590 And the usage for this one could be like kick or boot. 83 00:04:44,590 --> 00:04:45,970 We want to boot a player out. 84 00:04:45,970 --> 00:04:47,080 We could do that as well. 85 00:04:47,260 --> 00:04:52,480 And this is also going to require a string or aka the message we want to give to the player when we 86 00:04:52,510 --> 00:04:53,200 kick them. 87 00:04:54,280 --> 00:04:58,270 And then what we want to do here is we want to loop through every single player, pass this function, 88 00:04:58,690 --> 00:05:03,100 and before we kick them, we got to make sure that they're not an admin as well. 89 00:05:03,100 --> 00:05:07,420 So we're going to get the rank of this player using our comms bind able. 90 00:05:07,840 --> 00:05:12,820 And we're going to invoke to get the rank of this particular player. 91 00:05:12,820 --> 00:05:18,010 So if you remember in our admin handler, if we go down to our on invoke function, we get the rank 92 00:05:18,010 --> 00:05:19,090 of a player. 93 00:05:19,360 --> 00:05:29,410 And then we can go and check to see if this rank is greater than zero or admin enum dot non-admin. 94 00:05:30,250 --> 00:05:36,130 Then we're going to return false and tell them that you cannot kick an admin. 95 00:05:36,130 --> 00:05:37,240 You can't do that. 96 00:05:37,240 --> 00:05:39,280 No kicking admins allow. 97 00:05:39,940 --> 00:05:45,310 Otherwise, if they aren't an admin, then we can just go ahead and kick them and give them the reason 98 00:05:45,310 --> 00:05:46,720 for why they were kicked. 99 00:05:46,720 --> 00:05:54,940 So in here we need to pass a message which is going to be our string, and we can give them the reason 100 00:05:54,940 --> 00:05:56,410 for why they were kicked. 101 00:05:56,920 --> 00:05:59,560 Another popular command is to ban somebody. 102 00:05:59,560 --> 00:06:03,850 So let me copy this and we can call this one ban. 103 00:06:05,500 --> 00:06:10,930 So give it a name of band and we can up the minimum rank to be administrator. 104 00:06:11,870 --> 00:06:14,930 And the usage for this one can just be banned. 105 00:06:15,260 --> 00:06:18,230 And for this one we can also require a player and a string. 106 00:06:18,620 --> 00:06:21,140 And in here we want to make sure we do the same thing. 107 00:06:21,140 --> 00:06:24,200 We want to make sure that this person is not an admin. 108 00:06:24,200 --> 00:06:28,520 If they are an admin then we can say cannot ban an admin. 109 00:06:28,580 --> 00:06:36,800 Otherwise we can create a message and we're going to set it equal to you have been server banned and 110 00:06:36,800 --> 00:06:37,940 we can give them the reason. 111 00:06:37,940 --> 00:06:40,520 And we're going to concatenate our reason string. 112 00:06:41,390 --> 00:06:47,840 And then what we could do is that inside of our admin setting, we're going to access server bands, 113 00:06:47,840 --> 00:06:53,030 and we're going to create a new key value pair in here using the player's user ID. 114 00:06:53,570 --> 00:06:56,240 And we're going to give them this band message. 115 00:06:56,240 --> 00:07:00,170 And then we're going to go ahead and kick this person and give them that message. 116 00:07:00,170 --> 00:07:05,630 So now that because we've inserted this person into our server band's table, any time they try to join 117 00:07:05,630 --> 00:07:11,990 back into the server, they're going to get kicked immediately and given this same server band message. 118 00:07:12,880 --> 00:07:19,000 Now, what if we wanted to go ahead and set the moderator or administrator of a player? 119 00:07:19,000 --> 00:07:23,860 What if we want to give them temporary moderator or permanent moderator or admin and stuff like that? 120 00:07:23,860 --> 00:07:26,560 Well, we can go ahead and create some commands for that. 121 00:07:26,680 --> 00:07:31,990 So for one we can create somebody as a temporary moderator. 122 00:07:31,990 --> 00:07:34,060 We can just call this command mod. 123 00:07:34,510 --> 00:07:41,260 The usage could be something like set mod, we could do temp mod. 124 00:07:41,260 --> 00:07:44,350 Actually I think that would be a good first usage. 125 00:07:44,350 --> 00:07:51,670 So temp mod we could do set mod or we could do server mod or something like that. 126 00:07:51,670 --> 00:07:54,400 And all we need is a player to be passed to the function. 127 00:07:54,520 --> 00:07:59,830 And then what we could do here is we could loop through every single player pass to our callback, and 128 00:07:59,830 --> 00:08:05,230 then we could use our coms bindable again and invoke to. 129 00:08:06,460 --> 00:08:09,910 Set temporary privileges. 130 00:08:10,460 --> 00:08:12,200 For this particular player. 131 00:08:12,200 --> 00:08:19,430 So pass a table with the player and then we could also pass what, um, rank we want to give to this 132 00:08:19,430 --> 00:08:19,760 player. 133 00:08:19,760 --> 00:08:22,640 In that case that's going to be admin enum dot moderator. 134 00:08:22,640 --> 00:08:26,630 So let's go ahead and fill out this set temp privileges action. 135 00:08:26,630 --> 00:08:32,210 So if we go back to our admin handler inside of set temp privileges, what we could do is we could get 136 00:08:32,210 --> 00:08:33,680 the key for this player. 137 00:08:33,740 --> 00:08:37,010 So remember args one is going to be player. 138 00:08:37,370 --> 00:08:40,430 And then args two is going to be the rank. 139 00:08:40,880 --> 00:08:42,650 So is the rank. 140 00:08:43,520 --> 00:08:47,840 So key is equal to two string args one dot user id. 141 00:08:49,630 --> 00:08:55,150 And then the first thing we want to check is we want to check if this person exists within the admin 142 00:08:55,150 --> 00:08:57,370 settings.py ranks. 143 00:08:57,400 --> 00:09:01,810 So if they're already hard coded into our game, then we're going to return false and tell them that 144 00:09:01,810 --> 00:09:10,450 you cannot set temporary cannot set temporary privileges for a hard coded user. 145 00:09:12,760 --> 00:09:20,590 Otherwise, what we could do is we could check to see if they are within our data store. 146 00:09:20,590 --> 00:09:23,050 So we're going to use the Pcall function. 147 00:09:23,050 --> 00:09:25,600 And we're going to access our admin data store. 148 00:09:25,990 --> 00:09:31,570 And there's a function in there called get async which is to get a value in our data store. 149 00:09:31,570 --> 00:09:34,990 Again remember we have to pass the admin data store itself. 150 00:09:34,990 --> 00:09:36,790 And then we're going to pass the key. 151 00:09:36,940 --> 00:09:43,330 And then from here we can store the results or the success and result from this P call. 152 00:09:43,330 --> 00:09:44,860 And our get async function. 153 00:09:45,490 --> 00:09:53,050 If we were not successful in grabbing any data from this user, then we're going to return false and 154 00:09:53,050 --> 00:10:03,310 say um, a problem occurred with grabbing information from the data store, and we can give them the 155 00:10:03,310 --> 00:10:08,170 problem by formatting with the result from our Pcall function. 156 00:10:09,730 --> 00:10:18,550 Otherwise, if we, uh, were successful and there is a result or a value, then we need to return false 157 00:10:18,550 --> 00:10:21,790 and tell them temporary privileges. 158 00:10:24,590 --> 00:10:31,610 Cannot override permanent privileges for user. 159 00:10:32,630 --> 00:10:38,390 So if we try to give somebody temporary privileges and they already have permanent privileges, then 160 00:10:38,390 --> 00:10:40,190 we don't want to do anything at all. 161 00:10:40,190 --> 00:10:42,860 We're just going to tell them false and hey, we can't do that. 162 00:10:42,980 --> 00:10:47,480 Otherwise, if we make it through all that and we're all good to go, then we can do admin settings, 163 00:10:47,480 --> 00:10:55,850 dot temporary mods, create a new key value pair in there, and our new temporary mod is going to be 164 00:10:56,120 --> 00:11:00,320 of the rank that was passed to our on invoke function. 165 00:11:00,320 --> 00:11:04,010 So for this particular player it's going to be a moderator. 166 00:11:04,220 --> 00:11:09,170 And then we can call our setup admin for function and pass our player which is args one. 167 00:11:09,170 --> 00:11:11,570 And then we can return true. 168 00:11:11,600 --> 00:11:15,440 And then for setting permanent privileges it's going to be pretty similar. 169 00:11:15,770 --> 00:11:19,130 Um, the first thing we want to make sure of is that we're not running in studio. 170 00:11:19,130 --> 00:11:27,350 So if run service is studio, oops is studio, then we're going to return false and tell them we cannot 171 00:11:27,350 --> 00:11:29,780 set data store in studio. 172 00:11:31,840 --> 00:11:32,260 Otherwise. 173 00:11:32,260 --> 00:11:34,330 Again we're going to get the key for this player. 174 00:11:38,300 --> 00:11:39,350 So again. 175 00:11:40,400 --> 00:11:45,380 ARGs, one is a player and then args two is the rank. 176 00:11:45,530 --> 00:11:50,750 We're going to check inside of admin settings dot player ranks to make sure they are not a hardcoded 177 00:11:50,750 --> 00:11:51,290 user. 178 00:11:51,290 --> 00:11:57,800 If they are, then we're going to return false and say cannot set permanent privileges. 179 00:11:58,810 --> 00:12:00,760 For a hard coded user. 180 00:12:02,520 --> 00:12:05,490 Otherwise, what we could do is we could do admin settings. 181 00:12:05,490 --> 00:12:09,000 Uh, we can just set them inside of the temporary mods table. 182 00:12:09,000 --> 00:12:13,980 That way it's faster for our git rank function to find this player. 183 00:12:15,810 --> 00:12:19,380 And then we're also going to store them within the data store. 184 00:12:19,380 --> 00:12:20,700 So we call. 185 00:12:21,870 --> 00:12:23,430 Admin data store. 186 00:12:24,970 --> 00:12:28,060 And we're going to use the set async function again. 187 00:12:28,060 --> 00:12:34,900 Pass the data store itself and then the key for the data store. 188 00:12:35,290 --> 00:12:39,580 And then the value we want to store at that key which is going to be argument number two. 189 00:12:40,210 --> 00:12:45,490 If we were successful in setting up the data store, then we want to set up admin for this player. 190 00:12:48,430 --> 00:12:50,200 And then we can go ahead. 191 00:12:50,200 --> 00:12:51,790 Return. 192 00:12:52,920 --> 00:12:59,970 Success and result at the end here and again, I'm storing this player inside of our temporary mods 193 00:12:59,970 --> 00:13:01,350 uh, table. 194 00:13:01,350 --> 00:13:06,840 That way it's easier for when we call our git rank, uh, function. 195 00:13:06,840 --> 00:13:13,530 It can just go ahead and look inside of this table without having to, uh, use any async functions 196 00:13:13,530 --> 00:13:15,870 to grab information from the data stored. 197 00:13:16,910 --> 00:13:17,360 Otherwise. 198 00:13:17,360 --> 00:13:21,890 Last one we could fill out here is for removing privileges off of a player. 199 00:13:22,010 --> 00:13:26,690 So again we could do if run service is studio. 200 00:13:27,860 --> 00:13:31,880 Then we're going to return false because again, we don't want to mess with data stores in studio, 201 00:13:31,880 --> 00:13:35,870 so cannot set data store in studio. 202 00:13:37,380 --> 00:13:39,390 Otherwise we're going to get the key for this player. 203 00:13:39,390 --> 00:13:43,230 So two string args one dot user id. 204 00:13:43,500 --> 00:13:49,080 So this is going to be the same thing across the board here args one. 205 00:13:49,930 --> 00:13:52,450 Is a player and args two. 206 00:13:52,480 --> 00:13:54,220 Actually, we don't even need argument number two. 207 00:13:54,220 --> 00:13:55,540 It's just going to be the player. 208 00:13:56,430 --> 00:14:02,610 Anyways, we get there, uh, ki and then, uh, the first thing we want to check is if there are a 209 00:14:02,610 --> 00:14:03,450 hardcoded user. 210 00:14:03,450 --> 00:14:12,420 So if player ranks and we find them, then we're going to return false and tell them cannot revoke perms 211 00:14:12,420 --> 00:14:17,550 of a hardcoded user because there's no point. 212 00:14:18,360 --> 00:14:25,950 Otherwise if they have a key value pair within our admin settings dot temporary mods, then we can just 213 00:14:25,950 --> 00:14:28,080 set that to nil. 214 00:14:31,860 --> 00:14:34,800 And then we're going to access our data store again. 215 00:14:34,800 --> 00:14:38,280 So success result is equal to p call. 216 00:14:38,280 --> 00:14:40,560 And actually I'm going to pass a lambda function here instead. 217 00:14:40,560 --> 00:14:47,310 Because what we want to do is we want to see if there's a result within admin data store, get async 218 00:14:47,310 --> 00:14:48,660 and pass this key. 219 00:14:49,020 --> 00:14:56,820 If there is a result then we want to do admin data store uh remove async and pass the key. 220 00:14:56,820 --> 00:14:59,280 So we're removing this player from our data store. 221 00:14:59,580 --> 00:15:06,960 If we're successful in doing that then we can go ahead and remove admin from this player. 222 00:15:08,150 --> 00:15:14,570 And then at the very end, we can go ahead and return success and the results. 223 00:15:15,700 --> 00:15:16,150 All right. 224 00:15:16,150 --> 00:15:16,870 Very cool. 225 00:15:16,870 --> 00:15:19,810 So let's go ahead and go back to our commands module script. 226 00:15:20,740 --> 00:15:26,140 And then we can store the success and result from our bindable. 227 00:15:26,860 --> 00:15:32,980 And if we were not successful in setting this player as a temporary moderator, then we're just going 228 00:15:32,980 --> 00:15:44,710 to return false and say, encountered a problem setting temporary privileges for player, and we're 229 00:15:44,710 --> 00:15:46,480 going to put a directive here. 230 00:15:47,020 --> 00:15:49,810 And we can tell them that the error was this. 231 00:15:49,810 --> 00:15:52,690 And we're going to put again another directive. 232 00:15:53,290 --> 00:15:58,780 And then we can go ahead and format this string and pass the player name. 233 00:16:00,290 --> 00:16:04,430 And then the result from our bindable. 234 00:16:05,230 --> 00:16:09,820 If we were successful in setting them as a temporary moderator, then what I want to do is I want to 235 00:16:09,820 --> 00:16:15,190 use the task delay function, and I want to delay a function from running for five seconds. 236 00:16:17,910 --> 00:16:23,070 Because what's going on here is that if we were successful in setting temporary privileges for a player, 237 00:16:23,070 --> 00:16:28,680 that means the guy, if they had one, got destroyed and then a new one was added back to him. 238 00:16:28,680 --> 00:16:34,470 So I'm delaying this function by five seconds just to give that player enough time to replicate that 239 00:16:34,470 --> 00:16:40,350 guy on their end and run all the code in the GUI before we fire to the client to display them a message 240 00:16:40,350 --> 00:16:45,210 on their screen, because we're going to use the comms event and fire to this client. 241 00:16:46,290 --> 00:16:51,510 That we want them to display a message, and the message is going to be something like this. 242 00:16:51,540 --> 00:16:54,270 We could tell them that oops. 243 00:16:56,710 --> 00:17:03,100 We could tell them that, uh, you have been granted server moderator. 244 00:17:03,680 --> 00:17:09,050 And then we can kind of do a similar process here for giving somebody a permanent moderator. 245 00:17:09,050 --> 00:17:10,730 So we could do permanent mod. 246 00:17:11,360 --> 00:17:15,500 Uh, we'll call this permanent mod. 247 00:17:15,860 --> 00:17:21,320 And the usage for this one could be like uh, just parm mod. 248 00:17:22,430 --> 00:17:24,350 We only need a player here. 249 00:17:24,620 --> 00:17:31,520 And again we're going to invoke our comms bind able to instead set permanent privileges for this player. 250 00:17:31,520 --> 00:17:37,700 And then again if that wasn't successful we're going to tell them that we encountered a problem setting 251 00:17:37,940 --> 00:17:40,850 permanent privileges for this player. 252 00:17:41,390 --> 00:17:46,580 Otherwise if we were successful again we're going to wait five seconds and then tell the player that 253 00:17:46,580 --> 00:17:47,990 they've been granted. 254 00:17:49,010 --> 00:17:51,260 Permanent moderator. 255 00:17:51,620 --> 00:17:52,160 And guess what? 256 00:17:52,160 --> 00:17:59,270 We could do the exact same thing for giving a player temporary admin so we can go ahead and create a 257 00:17:59,270 --> 00:18:00,590 new key value pair. 258 00:18:00,590 --> 00:18:03,020 We're going to call this command admin. 259 00:18:03,260 --> 00:18:13,730 The name is going to be just admin and the usage can be temp admin set admin server admin. 260 00:18:13,730 --> 00:18:15,770 We could do a bunch of different usages here. 261 00:18:16,700 --> 00:18:22,400 And we're going to basically, again, do the exact same thing here, set temporary privileges. 262 00:18:22,400 --> 00:18:26,690 And that's going to be of the privileges dot admin. 263 00:18:26,870 --> 00:18:30,620 Otherwise if it's not successful again we give them an error message. 264 00:18:30,620 --> 00:18:36,020 Otherwise if we were successful we're going to tell them you have been granted server admin. 265 00:18:36,530 --> 00:18:40,250 And one last time let's go ahead and copy this function here. 266 00:18:40,250 --> 00:18:43,550 And let's do it for giving somebody permanent admin. 267 00:18:43,550 --> 00:18:47,030 So Perme admin we'll do permanent admin. 268 00:18:47,030 --> 00:18:49,580 And we can actually change the minimum rank for this too. 269 00:18:49,610 --> 00:18:52,400 So we could set this to be an owner only command. 270 00:18:52,730 --> 00:18:54,200 So owner only. 271 00:18:54,850 --> 00:18:58,960 So if we want to give somebody permanent admin again set firm privileges. 272 00:18:58,960 --> 00:19:01,150 We'll set this to admin. 273 00:19:02,200 --> 00:19:08,380 Again encountered a problem and then you have been granted permanent admin. 274 00:19:08,560 --> 00:19:14,140 Last but not least, we can create a command for getting rid of admin of a player. 275 00:19:14,140 --> 00:19:16,240 So we call this remove admin. 276 00:19:17,360 --> 00:19:21,680 We can give the name something like remove privileges. 277 00:19:22,230 --> 00:19:24,720 This will be an own or only command. 278 00:19:25,020 --> 00:19:33,060 The usage will be something like we could do revoke perms or we could do remove perms, whatever. 279 00:19:34,540 --> 00:19:39,910 And then what I want to do inside of this for loop is I want to use our comms bindable, and I want 280 00:19:39,910 --> 00:19:46,870 to invoke the action of removing privileges for this particular player here. 281 00:19:47,790 --> 00:19:52,410 And again we can create two variables success and result. 282 00:19:52,950 --> 00:19:57,810 If we were not successful and removing the privileges for this player, we're going to return false 283 00:19:57,810 --> 00:20:06,180 and give a message like encountered a problem removing privileges for player. 284 00:20:06,660 --> 00:20:10,200 Put a directive in here and then give an error message. 285 00:20:10,200 --> 00:20:12,210 So we'll need another directive. 286 00:20:13,930 --> 00:20:19,810 Format this function to replace those directives with the player name, and then the result from our 287 00:20:19,810 --> 00:20:21,520 invoke function. 288 00:20:22,040 --> 00:20:22,760 All right. 289 00:20:22,760 --> 00:20:25,310 And then that's all we need to do for that one. 290 00:20:25,310 --> 00:20:29,900 So now that we've got these neat little functions set up, let's go ahead and test them out. 291 00:20:33,910 --> 00:20:36,010 So let me open up my command line here. 292 00:20:36,190 --> 00:20:38,530 If I type in my colon, there we go. 293 00:20:38,530 --> 00:20:44,200 Shows all of the commands that I have access to use, such as permanent modding, a player, killing 294 00:20:44,200 --> 00:20:49,240 a player, revoking permissions, banning a player temporary, all that fun stuff. 295 00:20:49,810 --> 00:20:52,930 So let's go ahead and try to ban myself, which shouldn't work. 296 00:20:52,930 --> 00:20:58,480 So if I do ban me and I give a message like you suck, we're going to get a problem. 297 00:20:58,480 --> 00:21:01,210 The command ban encountered a problem during execution. 298 00:21:01,210 --> 00:21:02,860 Cannot ban an admin. 299 00:21:02,860 --> 00:21:07,900 Hey, you can't ban us because I'm the owner of the game again, this is the same problem if we were 300 00:21:07,900 --> 00:21:09,490 trying to kick an admin. 301 00:21:09,490 --> 00:21:14,680 So if I do kick me hahaha again, cannot kick an admin. 302 00:21:14,680 --> 00:21:18,400 All right, what if I try to set permanent privileges for myself? 303 00:21:18,400 --> 00:21:24,340 So if I do like temp oops temp admin me we can't do that. 304 00:21:24,340 --> 00:21:27,190 The command admin encountered a problem during execution. 305 00:21:27,190 --> 00:21:33,220 The problem is we encountered a problem setting temporary privileges for us because we cannot set temporary 306 00:21:33,220 --> 00:21:35,440 privileges for a hardcoded user. 307 00:21:35,710 --> 00:21:36,550 Cool. 308 00:21:36,850 --> 00:21:41,110 What if we try to give permanent moderator to myself? 309 00:21:41,760 --> 00:21:45,180 Again cannot set data store in studio. 310 00:21:45,270 --> 00:21:47,940 If I try to do permanent, uh, admin. 311 00:21:47,940 --> 00:21:49,590 Oops, looks like I forgot to change the name. 312 00:21:49,590 --> 00:21:51,090 So permanent admin me. 313 00:21:52,090 --> 00:21:53,290 The command doesn't exist. 314 00:21:53,290 --> 00:21:54,910 Think I forgot to change a name in here? 315 00:21:55,240 --> 00:21:56,170 Let me go back. 316 00:21:57,370 --> 00:21:59,140 Palm admin admin. 317 00:21:59,140 --> 00:22:00,940 Oh, let me change that usage there. 318 00:22:00,940 --> 00:22:02,470 So palm admin. 319 00:22:04,620 --> 00:22:04,950 Okay. 320 00:22:04,950 --> 00:22:05,610 It looks good. 321 00:22:07,990 --> 00:22:10,390 So let's go ahead and test that out. 322 00:22:11,320 --> 00:22:14,110 So we could do palm admin. 323 00:22:14,110 --> 00:22:15,130 Me again. 324 00:22:15,130 --> 00:22:18,400 We're going to get an error that we cannot set data stores in studio. 325 00:22:18,730 --> 00:22:21,550 And of course I can also use these commands from chat. 326 00:22:21,550 --> 00:22:28,810 So if I try to do something like set speed me 100, we're going to have no problem doing that whatsoever. 327 00:22:28,810 --> 00:22:35,170 But if I screw up and do set speed me something like, actually, let me change this to a string. 328 00:22:36,790 --> 00:22:42,100 We're going to get a problem there because we didn't enter in the correct argument for that parameter. 329 00:22:43,550 --> 00:22:48,890 And again, I could do something like, well, let's say I type in a command that doesn't exist. 330 00:22:48,890 --> 00:22:57,260 So like, uh, something blah, blah blah, we're going to get command does not exist, but I can go 331 00:22:57,260 --> 00:22:59,600 ahead and kill myself using the kill me. 332 00:23:00,960 --> 00:23:04,170 Alrighty, so congratulations on finishing this project. 333 00:23:04,170 --> 00:23:05,250 We are done! 334 00:23:05,250 --> 00:23:10,440 Hopefully you've gained a solid understanding of how an admin system works and how you can create your 335 00:23:10,440 --> 00:23:12,450 own admin systems and commands. 336 00:23:12,450 --> 00:23:17,160 The completed model is attached to this lecture along with some additional functions I've added inside 337 00:23:17,160 --> 00:23:18,450 of our admin system. 338 00:23:18,480 --> 00:23:19,890 I'll see you in the next lecture.